package com.open.source;

import java.nio.charset.Charset;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.HashMap;
import java.util.Map;
import lombok.extern.slf4j.Slf4j;
import org.apache.kafka.common.config.TopicConfig;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

/**
 * @author ZonLen since on 2022/7/29 下午12:19
 */
@Slf4j
@SpringBootApplication
public class KafkaConsumerApplication {

  public static void main(String[] args) {
    SpringApplication.run(KafkaConsumerApplication.class, args);
    final Map<String, String> configs = new HashMap<>();
    //retention.ms
    configs.put(TopicConfig.RETENTION_MS_CONFIG, 720 * 3600 + "");
    int index = 0;
//    do {
    final String dateFormat = LocalDateTime.now()
        .format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:dd:ss"));
    final HashMap<String, Object> data = new HashMap<>();
    data.put("index", index++);
    data.put("tmp", dateFormat);
    final String value = new String("张龙".getBytes(), Charset.forName("GBK"));
    data.put("val", value);
//    final String gbk = new String(JSON.toJSONString(data).getBytes(Charset.forName("GBK")));
    System.out.println("-------" + data.toString());
    MqSenderAdaptor.send(MqManagerEnum.TAX_TOPIC_DELAY_DEMO,
        data.toString().getBytes());
//      Thread.sleep(5000);
//    } while (true);
  }

}
